package com.baozun.houji.me.adapter

import com.baozhun.mall.common.base.BaseListAdapter
import com.baozhun.mall.common.model.bean.AddressInfo
import com.baozun.houji.me.BR
import com.baozun.houji.me.R
import com.baozun.houji.me.databinding.ItemAddressListBinding
import com.chad.library.adapter.base.listener.OnItemChildClickListener
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder

/**
 * @Title：
 * @Description：
 * @Author：xing.luo
 * @Since：2022/11/27
 * @Version：1.0.0
 */
class AddressListAdapter(data: MutableList<AddressInfo>, val listener: OnItemChildClickListener) :
    BaseListAdapter<AddressInfo, ItemAddressListBinding>(
        R.layout.item_address_list, data
    ) {

    override fun convert(holder: BaseDataBindingHolder<ItemAddressListBinding>, item: AddressInfo) {
        super.convert(holder, item)
        holder.dataBinding?.setVariable(BR.model, item)
        holder.dataBinding?.executePendingBindings()
        holder.dataBinding?.setDefaultLayout?.isSelected = item.isDefault()
        holder.dataBinding?.setDefaultLayout?.setOnClickListener {
            listener.onItemChildClick(this, it, getItemPosition(item))
        }
    }


}